﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

/// <summary>
///Work 的摘要说明
/// </summary>
public class Work
{
	public Work()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}
    public System.IO.Stream s;
    
    public void SetPost()
    {
        try
        {
            int count = 0;
            byte[] buffer = new byte[1024];
            StringBuilder builder = new StringBuilder();
            while ((count = s.Read(buffer, 0, 1024)) > 0)
            {
                builder.Append(Encoding.UTF8.GetString(buffer, 0, count));
            }
            s.Flush();
            s.Close();
            s.Dispose();
            string POSTStr = builder.ToString();
            if (!string.IsNullOrEmpty(POSTStr))
            {
                string[] Arr = POSTStr.Split('&');
                model m = new model();
                for (int i = 0; i < Arr.Length; i++)
                {
                    string[] strarr = Arr[i].Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                    switch (strarr[0])
                    {
                        case "fild1":
                            m.IP = strarr[1];
                            break;
                        case "fild2":
                            m.ID = strarr[1];
                            break;
                    }
                }
                m.TimeStr = DateTime.Now.ToString();
                toole.listmodel.Add(m);
                ThreadingListWork.AddWork(new AddSqlite());
            }
        }
        catch (Exception ee)
        {
            toole.WriteFile(ee.Message + "\r\n" + ee.Source + "\r\n" + ee.StackTrace);
        }
    }
}